<?php

/**
 * 水印相关
 */
class watermarksModel
{


    public function __construct(& $base)
    {
        $this->base = $base;
        $this->db = & $this->base->db;
        $this->redis = & $this->base->redis;
    }

    /**
     * 获取水印列表
     * @param integer $limit
     * @return array
     */
    public function getList($limit = 100)
    {
        return $this->db->getAll("select * from r_watermarks order by wid desc limit {$limit}");
    }

    /**
     * 通过水印ID获取单条水印信息
     * @param integer $wid
     * @return array
     */
    public function getRowByWid($wid)
    {
        return $this->db->getRowTable('r_watermarks', array(), "wid='{$wid}'");
    }

    /**
     * 通过水印ID删除单条水印信息
     * @param integer $wid
     * @return boolean
     */
    public function delRowByWid($wid)
    {
        return $this->db->delDataTable('r_watermarks', "wid='{$wid}'");
    }

    /**
     * 通过水印ID更新单条水印信息
     * @param integer $wid
     * @param array $data
     * @return boolean
     */
    public function updateRow($wid, array $data)
    {
        $data['wid'] = $wid;

        return $this->db->updateRowTable('r_watermarks', $data);
    }

    /**
     * 添加单条水印信息
     * @param integer $wid
     * @param array $data
     * @return integer
     */
    public function insertRow(array $data)
    {
        return $this->db->insertRowTable('r_watermarks', $data);
    }

}